<!DOCTYPE html>
<html>
<% include ./user_component/head.ejs%>
<script src="/js/vue.js"></script>
<style>
    .userImage {
        margin: 0 0 30px 110px;
    }

    .layui-form-item .layui-input-inline {
        width: 580px;
    }

    .add-icon {
        background-image: url('/images/fuhao.jpg');
        background-repeat: no-repeat;
        background-attachment: scroll;
        background-position: 1px 2px;
        background-size: 230px 140px;
        width: 40px;
        height: 40px;
        cursor: pointer;
    }
    .delete-icon {
        background-image: url('/images/fuhao.jpg');
        background-repeat: no-repeat;
        background-attachment: scroll;
        background-position: -46px 2px;
        background-size: 230px 140px;
        width: 40px;
        height: 40px;
        cursor: pointer;
    }
    .answer-label{
        margin-right: 20px;
    }
</style>

<body>
    <div class="x-body" id="page">

            <div class="layui-form-item">
                <label for="questionTitle" class="layui-form-label">
                    考试主题
                </label>
                <div class="layui-input-inline">
                    <input type="text" v-model="title" id="questionTitle" name="questionTitle" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    将会成为题目
                </div>
            </div>
            <div class="layui-form-item">
                <label for="questionTitle" class="layui-form-label">
                    时间
                </label>
                <div class="layui-input-inline">
                    <input type="text" v-model="date" id="questionTitle" name="questionTitle" class="layui-input">
                </div>
                <div class="layui-form-mid layui-word-aux">
                    将会成为时间
                </div>
            </div>

            <div class="layui-form-item">
                <label for="L_repass" class="layui-form-label">
                </label>
                <button class="layui-btn" @click="confirm">
                    增加
                </button>
            </div>

    </div>
    <script>
        var page = new Vue({
            el: '#page',
            data: {
                title: '',
                date:''
            },
            methods: {
                confirm() {
                    let data = {}
                    data.title = this.title
                    data.date = this.date
                        $.ajax({
                        url: '/api/addExamination',
                        method: 'POST',
                        header: {
                            'content-type': 'application/json' // 默认值
                        },
                        data: data,
                        success: function (e) {
                            //发异步，把数据提交给php
                            layer.alert("修改成功", { icon: 6 }, function () {
                                // 获得frame索引
                                var index = parent.layer.getFrameIndex(window.name);
                                //关闭当前frame
                                if (parent) {
                                    parent.layer.close(index);
                                }
                                parent.history.go(0)
                            });
                        },
                        fail: function (err) {
                            console.log(err);
                        },
                        complete: function (e) {
                        }
                    }
                    )
                }
            }
        })
    </script>
</body>

</html>
